<!DOCTYPE html> 
<html lang="en"> 
<head> 

    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>自定义数据表</title> 
   
    <style type="text/css">
        @import url("/pages/import/base.css");
        html, body{ margin:0; height:100%; }
    </style>
    <script type="text/javascript" src="/pages/import/base.js"></script>
    
</head> 
<body class="easyui-layout" style="overflow: hidden;">
  <script type="text/javascript">
  </script>
    <div data-options="region:'center',iconCls:'icon-reload',title:'',split:true" style="width:70%;height: 100%">
        <table id="dg" class='easyui-datagrid' style="width:100%;height:100%" title="" data-options="
                  rownumbers:true,
                  singleSelect:true,
                  autoRowHeight:false,
                  pagination:true,
                  fitColumns:false,
                  striped:true,
                  checkOnSelect:true,
                  selectOnCheck:true,
                  collapsible:true,
                  toolbar:'#tb',
                  pageSize:20">
            <thead>
                <tr href="#">                      
                <th field="uuid" align="center">uuid</th>
                <th field="name" align="center">名称</th>
                <th field="url" align="center">连接地址</th>
              </tr>
            </thead>
          </table>    
          <div id="tb" style="height:35px">
            <a id='btnNewUser' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-plus',plain:true" onclick="add()">新增</a>
            <a id='btnEditUser' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-pencil',plain:true" onclick="edit()">修改</a>
            <a id='btnViewUser' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-trash',plain:true" onclick="dele()">删除</a>
            <a id='btnViewUser' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-trash',plain:true" onclick="preview()">测试</a>
          </div>
       </div>
    </div>
    


</body>

<script type="text/javascript">
  
$(function() {
    loadDatagraid();
});

</script>
<script type="text/javascript">
    function loadDatagraid() {

        $('#dg').datagrid({
            url: '/develop/url/getUrl.do',
            queryParams: {
                name: 'getAllPageTemplate'
            },
            method: 'get',
            onLoadSuccess:function(data)
            {

            }
        })
    }
</script>
<script type="text/javascript">
    function add() {
        Easyui.Layer.openAddLayerWindow('新增数据表格','form/addDateTemplate.html',['800px','600px']);
    }
    function edit() {
        var row = Easyui.Datagraid.getSelectRow('dg');
        if (row == null) {
            layerMsgCustom('必须选择一条数据');
            return;
        }
        window.open( 'form/editDateTemplate.html?uuid=' + row.uuid, "_blank"); 

        // Easyui.Layer.openAddLayerWindow(
        //     '修改数据表格',
        //     'form/editDateTemplate.html?uuid=' + row.uuid,
        //     ['800px','600px']
        // );
    }    
    function dele()
    {
        var row = Easyui.Datagraid.getSelectRow('dg');
        if (row == null) {
            layerMsgCustom('必须选择一条数据');
            return;
        }
        $.ajax({
            url:'/develop/pagetemplate/deleteDatagraidAndColumns.do',
            type: "POST",
            dataType: 'json',
            data: {
                'uuid': row.uuid
            },
            error: function() //失败
            {
                shuoheUtil.layerTopMaskOff();
            },
            success: function(data) //成功
            {
                shuoheUtil.layerTopMaskOff();
                if (data.result == true) {
                    shuoheUtil.layerClose();
                    parent.updateSuccess();
                } else
                    shuoheUtil.layerMsgCustom(data.describe);
            }
        });        
    }
    function preview()
    {
        var row = Easyui.Datagraid.getSelectRow('dg');
        if (row == null) {
            layerMsgCustom('必须选择一条数据');
            return;
        }
        Easyui.Layer.openAddLayerWindow('预览数据表格','form/preview.html?uuid='+row.uuid,['800px','600px']);
    }
</script>
<script type="text/javascript">
    function updateSuccess() {
        loadDatagraid();
    }

</script>